#!/bin/bash -ex

CMAKE_SCRIPT_DIR="$(realpath $(dirname ${0}))"
SCRIPT_DIR="$(dirname ${CMAKE_SCRIPT_DIR})"
ROOT_REPO_DIR="$(dirname ${SCRIPT_DIR})"

BUILD_DIR="${ROOT_REPO_DIR}/build"
mkdir -p "${BUILD_DIR}"

NPM_PANDA_DIR="${1:-/home/aleks/repos/idlize/external/incremental/tools/panda/node_modules/@panda/sdk/linux_host_tools}"

cd "${BUILD_DIR}"

rm -rf *
cmake \
"${ROOT_REPO_DIR}/CMakeLists.txt" \
-GNinja -B "${BUILD_DIR}" \
-DNPM_KOALA_PANDA_PATH="${NPM_PANDA_DIR}" \
-DUSE_LOCAL_BUILD_PANDA=OFF
